Conventionally, there has been known a game apparatus using an input device including an acceleration sensor. For example, there has been known a game program in which a player performs a “swing” motion of the input device and a game progresses, and the like.
When the player swings the above input device, the motion speeds up at the beginning of the swing, and speeds down at the end of the swing. Thus, after acceleration is generated in the input device in the same direction as the swinging direction at the beginning of the swing, the magnitude of the acceleration gradually decreases, and acceleration is generated in the input device in a direction opposite to the swinging direction at the end of the swing.
For that reason, concerning a determination of a “swing” motion, for example, in the case of determining occurrence of a swing motion when acceleration exceeds a predetermined threshold value, a determination is made as to whether acceleration in the same direction as the swinging direction exceeds the predetermined threshold value, and a determination is also made as to whether acceleration in a direction opposite to the swinging direction exceeds the predetermined threshold value. In other words, a determination is made twice as to whether acceleration exceeds the predetermined threshold value. As a result, even when the player intends to perform one “swing” motion, two “swing” motions may be detected.
In view of such inconvenience, a technique is disclosed, in which within a predetermined time period from a time when acceleration of an input device exceeds a predetermined threshold value, even if the acceleration exceeds the threshold value again, it is not detected as a “swing” motion (e.g. Japanese Laid-Open Patent Publication No. 2007-300973).
However, a program disclosed in Japanese Laid-Open Patent Publication No. 2007-300973 has problems as follows. In the case where the above predetermined time period from the time when the acceleration exceeds the predetermined threshold value is set long, when a player consecutively performs “swing” motions for a short time period, occurrence of “swings” is not accurately detected. In other words, in the case where the above predetermined time period is set as 2 seconds, when the player performs a “swing” motion five times for a short time period, i.e., 2 seconds, “swings” are not detected during the predetermined time period, and only one “swing” is detected in game processing. On the other hand, in the case where the predetermined time period is set short, wrong detection occurs due to acceleration in the direction opposite to the swinging direction as described above.
Therefore, an object of certain example embodiments provide a computer-readable storage medium storing an information processing program and an information processing device, each of which is capable of more accurately detecting a “swing” motion of an input device including an acceleration sensor.
Certain example embodiments include the following features to attain the object mentioned above. It is noted that reference characters and supplementary explanations in parentheses are merely provided to facilitate the understanding of certain example embodiments in relation to later-described embodiments, rather than limiting the scope of the present invention in any way.
A first aspect is a computer-readable storage medium storing an information processing program executed by a computer of an information processing device which executes processing based on acceleration data which is outputted from an acceleration sensor which detects acceleration in at least two axial directions which is applied to an input device. The information processing program causing the computer to function as acceleration data obtaining means (S31), change amount vector calculation means (S32, S34), first determination means (S27), processing execution means (S28), swinging direction calculation means (S3), second threshold value setting means (S4), second determination means (S4), and third determination means (S5). The acceleration data obtaining means obtains the acceleration data at a unit time interval. The change amount vector calculation means calculates, based on the acceleration data obtained by the acceleration data obtaining means, a change amount vector indicative of a change amount of acceleration. The first determination means determines at the unit time interval whether or not a magnitude of the change amount vector calculated by the change amount vector calculation means is equal to or larger than a first threshold value. The processing execution means executes predetermined processing when the first determination means determines that the magnitude of the change amount vector is equal to or larger than the first threshold value. When the first determination means determines that the magnitude of the change amount vector is equal to or larger than the first threshold value, the swinging direction calculation means calculates a swinging direction in which the input device is swung based on the change amount vector. After the swinging direction calculation means calculates the swinging direction, the second threshold value setting means sets at least one second threshold value in a direction opposite to the swinging direction. The second determination means determines whether or not the change amount vector intersects with the second threshold value. After the second determination means determines that the change amount vector intersects with the second threshold value, the third determination means determines whether or not the magnitude of the change amount vector is smaller than a third threshold value which is equal to or smaller than the first threshold value. When the first determination means determines that the magnitude of the change amount vector is equal to or larger than the first threshold value, the first determination means waits for the third determination means to determine that the magnitude of the change amount vector is smaller than the third threshold value, and then restarts the determination which is made at the unit time interval as to whether or not the magnitude of the change amount vector is larger than the first threshold value.
According to the first aspect, one swing motion which a player intends can be prevented from being wrongly detected as two swing motions.
In a second aspect based on the first aspect, the second threshold value setting means sets the second threshold value to be a value indicated as a straight line or a plane perpendicular to the swinging direction in a space based on a number of dimensions of the change amount vector. The second determination means determines whether or not a straight line indicated by the change amount vector intersects with the straight line or the plane perpendicular to the swinging direction in the space.
In a third aspect based on the second aspect, the second threshold value setting means sets the second threshold value to be the value indicated as the straight line or the plane which is located in a position distant from an origin in the space and in a direction opposite to the swinging direction.
According to the second or third aspect, the same advantageous effect as the first aspect can be obtained.
In a fourth aspect based on the first aspect, the swinging direction calculation means regards as the swinging direction a direction indicated by the change amount vector when the first determination means determines that the magnitude of the change amount vector is equal to or larger than the first threshold value.
In a fifth aspect based on the first aspect, when the first determination means determines that the magnitude of the change amount vector is equal to or larger than the first threshold value, the swinging direction calculation means regards as the swinging direction a direction indicated by a change amount vector based on acceleration data which is obtained after a predetermined time period elapses from a time of the determination.
In a sixth aspect based on the first aspect, the swinging direction calculation means includes combination vector calculation means (S55) for when the first determination means determines that the magnitude of the change amount vector is equal to or larger than the first threshold value, combining change amount vectors for a predetermined time period from a time of the determination to calculate a combination vector. The swinging direction calculation means regards a direction indicated by the combination vector as the swinging direction.
According to any of the fourth to sixth aspects, the swinging direction can be calculated more accurately.
In a seventh aspect based on the first aspect, the second threshold value setting means sets the second threshold value to be a value in accordance with the magnitude of the change amount vector when the first determination means determines that the magnitude of the change amount vector is equal to or larger than the first threshold value.
According to the seventh aspect, one swing motion can be prevented from being wrongly detected as two swing motions in accordance with strength of a swing by the player.
In an eighth aspect based on the first aspect, the information processing program further causes the computer to function as threshold value increase means (S21) for increasing the first threshold value in accordance with the magnitude of the change amount vector at a predetermined timing.
According to the eighth aspect, the determination as to whether or not the magnitude of the change amount vector is equal to or larger than the first threshold value can be prevented from being continuously made despite player's intention.
In a ninth aspect based on the eighth aspect, the information processing program further causes the computer to function as decrease means (S42) for gradually decreasing the first threshold value as time passes after the threshold value increase means increases the first threshold value.
According to the ninth aspect, an effect caused by a different manner of swinging by each player can be reduced.
In a tenth aspect based on the first aspect, the second determination means calculates an inner product between the change amount vector and the swinging direction, and compares the inner product with the second threshold value to determine whether or not the change amount vector intersects with the second threshold value.
According to the tenth aspect, a processing burden on the computer can be reduced.
An eleventh aspect is an information processing device for executing processing based on acceleration data which is outputted from an acceleration sensor which detects acceleration in at least two axial directions which is applied to an input device. The information processing device comprises acceleration data obtaining means (10), change amount vector calculation means (10), first determination means (10), processing execution means (10), swinging direction calculation means (10), second threshold value setting means (10), second determination means (10), and third determination means (10). The acceleration data obtaining means (10) obtains the acceleration data at a unit time interval. The change amount vector calculation means calculates, based on the acceleration data obtained by the acceleration data obtaining means, a change amount vector indicative of a change amount of acceleration. The first determination means determines at the unit time interval whether or not a magnitude of the change amount vector calculated by the change amount vector calculation means is equal to or larger than a first threshold value. The processing execution means executes predetermined processing when the first determination means determines that the magnitude of the change amount vector is equal to or larger than the first threshold value. When the first determination means determines that the magnitude of the change amount vector is equal to or larger than the first threshold value, the swinging direction calculation means calculates a swinging direction in which the input device is swung based on the change amount vector. After the swinging direction calculation means calculates the swinging direction, the second threshold value setting means sets at least one second threshold value in a direction opposite to the swinging direction. The second determination means determines whether or not the change amount vector intersects with the second threshold value. After the second determination means determines that the change amount vector intersects with the second threshold value, the third determination means determines whether or not the magnitude of the change amount vector is smaller than a third threshold value which is equal to or smaller than the first threshold value. When the first determination means determines that the magnitude of the change amount vector is equal to or larger than the first threshold value, the first determination means waits for the third determination means to determine that the magnitude of the change amount vector is smaller than the third threshold value, and then restarts the determination which is made at the unit time interval as to whether or not the magnitude of the change amount vector is larger than the first threshold value.
According to the eleventh aspect, the same advantageous effect as the first aspect can be obtained.
According to the eleventh aspect, a “swing” motion of the input device including the acceleration sensor can be detected more accurately.
These and other objects, features, aspects and advantages of certain example embodiments will become more apparent from the following detailed description when taken in conjunction with the accompanying drawings.